<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>我的订单</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
          integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous"/>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>

<div th:insert="head.html"></div>


<div class="container-fluid" id="app" style="margin-top: 180px;margin-bottom: 100px">


    <div class="container col-md-12" v-if="!orderList">
        <h3 style="text-align: center">还没有任何订单,快去下单吧~</h3>
    </div>


    <div class="row" v-if="orderList">
        <div class="container">
            <div>
                <div class="row" style="height: 40px ;line-height: 40px">
                    <div class="col-md-12">
                        <p style="background-color: #CCCCCC; font-size: 15px; line-height: 40px">订单编号:{{orderList.orderNum}} 下单时间:{{orderList.createdTime}}
                            总金额:{{orderList.totalprice}}元</p>
                    </div>
                </div>
                <div class="row p-3">
                    <div class="col-md-10 col-md-offset-1" v-for="orderVo in orderList.orderVo">
                        <table class="table">
                            <tr>
                                <th>图片</th>
                                <th>名称</th>
                                <th>购买数量</th>
                                <th>金额</th>
                            </tr>
                            <tr>
                                <td>
                                    <img style="height: 60px;width: 60px" :src="orderVo.Imgsrc" alt="...">
                                </td>
                                <td style="vertical-align: middle" v-text="orderVo.name">名称</td>
                                <td style="vertical-align: middle" v-text="orderVo.count">购买数量</td>
                                <td style="vertical-align: middle" v-text="orderVo.price">金额</td>
                            </tr>
                        </table>
                    </div>
                    <div class="col-md-1">
                        <!--订单状态 1.未支付  2 . 已支付  3.退款中  4. 已退款  5.已取消-->
                        <button class="btn btn-primary" v-if="orderList.status == 1">去支付</button>
                        <button class="btn btn-primary" v-if="orderList.status == 1">取消</button>
                        <button class="btn btn-primary" v-if="orderList.status == 2">退款</button>
                        <button class="btn btn-primary" v-if="orderList.status == 5">退款中...</button>
                        <button class="btn btn-primary" v-if="orderList.status == 3">已退款</button>
                        <button class="btn btn-primary" v-if="orderList.status == 4">已取消</button>
                    </div>
                </div>
            </div>
        </div>

    </div>

</div>


<script>

    console.log("------myOrder-----")

    let app = new Vue({
        el: "#app",
        data: {
            orderList: {}
        },
        methods: {
            initOrderList() {
                $.post("/order/listOrders", data => {
                    console.log(data)
                    this.orderList = data;
                })
            }
        },
        created() {
            this.initOrderList()
        }
    })

</script>


<div th:insert="foot.html"></div>


</body>
</html>